Skip to content

feat(viewer): design tokens (radius, type, spacing, colour, hairlines, motion) - #269

Open
NickAltstein wants to merge 3 commits into
mainfrom
feat/viewer-design-tokens
Open

NickAltstein wants to merge 3 commits into
mainfrom
feat/viewer-design-tokens

Conversation

@NickAltstein

Copy link
Copy Markdown
Owner

PR 2 of 6 in the viewer redesign. Design tokens only, with no intended change to the design. Branched from main @ b99b71e88 and independent of PR 1.

What changed

  • viewer/tokens.css (new) is loaded first on every page that uses the shared stylesheets: index, ledger, audit, verify, ledger/, r/, t/, check/, ufc/fighter.
    • Radius: --r-1 2px · --r-2 4px · --r-3 8px · --r-full
    • Type: --fs-1…--fs-7 = 11 / 12 / 14 / 16 / 20 / 28 / 36px. Nothing is under 11px. body { font-variant-numeric: tabular-nums }
    • Spacing: --sp-1…--sp-12 on a 4px grid
    • Colour: graphite surfaces --c-surface-0/1/2, --c-text, --c-text-muted, --c-text-faint, and one --c-accent. The existing --ps-* variables now alias these at the same values.
    • Hairline: --hairline: 1px solid rgba(255,255,255,0.06)
    • Motion: --dur-1 150ms, --dur-2 200ms, --ease-out, and a global prefers-reduced-motion rule
  • scripts/css_tokens_codemod.py (new) moves the literal values in style.css, terminal-ui.css, refresh-2026.css, design-system.css and ufc.css onto the tokens. It is idempotent, and --check exits 1 if a literal is left.
    • The mapping rules are in its docstring.
    • The old radius variables (--radius*, --rf-r*, --ps-radius) now point at the tokens.
  • scripts/visual/redesign-gates.mjs (new) is the evidence harness for this series.
    • It covers 5 scenarios (home, expanded player, Line Pricer, PARTIAL slate, no-quote card) at 375 / 390 / 430 / 768 / 1440, in dark mode.
    • Data is pinned to scripts/visual/redesign-data-ref. The file is byte-identical in PR 1.
  • Cache busters were bumped, the service worker CACHE_NAME changed, and public/ was mirrored.

Measured effect (rendered home page, 390 + 1440, all <details> open)

before after
distinct border radii 12 (2, 4, 6, 7, 8, 9, 10, 12, 14, 18, 50%, 999px) 4 tokens + 50% circles
distinct font sizes 19 (8–36px, including 116 SVG labels at 9px) 7 token steps + 2 fluid clamp() headings (22, 26px)
text under 11px yes (8, 9, 9.5, 10, 10.5px) none

Because spacing and small text moved onto the grid, the pixel diff is large: 28–35% of the home page changes at mobile widths. Elements below shift down a few pixels. The design itself is unchanged; compare side by side below.

Before / after

390 home (left = main, right = this PR)
390 home

390 no-quote cards
390 no-quote

1440 home
1440 home

All 25 after-screenshots (5 scenarios × 5 widths) and the gate report are in evidence/viewer-redesign/pr2.

Tests and gates

CHROME_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome" npm test

→ tests 217 · pass 217 · fail 0. Browser tests ran (Chrome found).

.venv/bin/python -m pytest tests --ignore=tests/ledger -q

→ 822 passed, 3 skipped

.venv/bin/python scripts/check_public_sync.py && python3 scripts/css_tokens_codemod.py --check

→ public/ matches viewer/ and contains no win-rate/ROI copy. · would change: nothing

node scripts/visual/redesign-gates.mjs .visual/gates --axe <axe.min.js>

Same results as main on every assertion; this PR fixes no layout bugs (that is PR 3/4):

  • no horizontal overflow: 25/25
  • bottom bar never covers content: 1/5 (fails at 375–768; fixed in PR 3)
  • book price on one line: fails where a quote wraps (PR 4)
  • each number once per card: 0/25 (PR 3)
  • axe, home at every width: button-name (critical, #headerSearchTrigger) and nested-interactive (serious, list cards). Both are also on main; PR 3/5 fix them. No color-contrast violations.

Lighthouse mobile (3 runs, local python3 -m http.server):

Performance LCP CLS TBT
main 11 / 37 / 38 25.6 / 11.4 / 10.1 s 0.762 / 0.006 / 0.006 1979 / 929 / 1755 ms
this PR 37 / 28 / 37 9.3 / 20.9 / 11.7 s 0.006 ×3 1883 / 3551 / 934 ms

Not met: Performance ≥90 and LCP <2.5s. main is far off too, and a token change can't close that gap. It needs separate work on the ~10k-line app.js boot and the slate JSON loaded at startup. CLS meets the <0.05 target.

Not done in this PR

  • Colour usage was not unified. Tokens exist, but quoted values still use the old blue (--quote) alongside the green accent. Moving to one accent changes how quote states look, so it goes in PR 4 (player row).
  • public.css and verify-landing.css (verify/landing pages) were not migrated, and they use rem sizes.
  • font-size/border-radius in JS-template style="" attributes were not migrated. Production CSP (style-src 'self') already blocks them.

🤖 Generated with Claude Code

NickAltstein and others added 3 commits November 24, 2026 16:52
…nes and motion

Adds viewer/tokens.css (loaded first on every page that uses the shared
stylesheets) and scripts/css_tokens_codemod.py, which moves literal values in
the viewer stylesheets onto the tokens. The codemod is idempotent and has a
--check mode.

- radius: 2 / 4 / 8 / full (rendered home page: 12 radii -> 4, plus 50% circles)
- type: 7 steps 11-36px, nothing under 11px; tabular-nums on body
  (rendered home page: 19 sizes -> 7 token steps + 2 clamp() display headings)
- spacing: padding/margin/gap snapped to a 4px grid (1-3px nudges kept)
- colour: graphite surfaces at 3 steps, one accent, muted metadata; the
  existing --ps-* variables now alias the tokens (same values)
- hairlines: 1px rgba(255,255,255,0.06)
- motion: 150/200ms ease-out; global prefers-reduced-motion rule

Also adds scripts/visual/redesign-gates.mjs, an evidence harness: 5 scenarios
x 5 widths, overflow / bottom-bar / one-line price / number-once assertions,
optional axe scan, on data pinned to scripts/visual/redesign-data-ref.

Presentation only: no model, pricing, gate or copy change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The token codemod changed viewer/ufc.css and bumped its ?v= to 2026_v201
in index.html and sw.js, but viewer/ufc/fighter.html still loaded
2026_v199, so returning visitors would get the old stylesheet there and
check_cache_busters.py failed CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tifacts

New workflow .github/workflows/viewer-gates.yml (pull requests touching viewer/
or scripts/visual/): captures the base branch and this PR with
scripts/visual/redesign-gates.mjs on the same pinned data, uploads both sets,
the pixel diffs and the reports as a workflow artifact, and fails only on a
regression vs the base branch (new --baseline mode): an assertion that passes
on base but fails here, or a new serious/critical axe rule. Failures base
already has are reported, not enforced.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant